﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Controllers
{
    public class GXPackageController : BaseController
    {
        public ActionResult Find(int start, int limit)
        {
            IQueryable<CMS_Product> list = from r in ctx.CMS_Product orderby r.OrderNo select r;
            CJson CJson = new CJson();
            string json = CJson.ToJsonString("totalCount:" + list.Count() + ",data", list.Skip(start).Take(limit).ToList());
            return Content(json);
        }
        public ActionResult Delete(int id)
        {
            var rdto = new ResultMessages();
            rdto.Message = "";
            CMS_Product model = ctx.CMS_Product.Single(q => q.Id == id);
            try
            {
                ctx.CMS_Product.DeleteOnSubmit(model);
                ctx.SubmitChanges();
                rdto.Message = "删除成功";
                rdto.Result = true;
            }
            catch (Exception ex)
            {
                rdto.Message = "删除失败";
                rdto.Result = false;
            }
            return Json(rdto);
        }
    }
}